package com.ericdm.callingandsmsstatistics;

import java.util.LinkedList;
import java.util.List;

import android.app.Activity;
import android.app.Application;

public class ExitApplication extends Application {
	private List<Activity> activityList = new LinkedList<Activity>();
	private static ExitApplication instance; 
	
	public static ExitApplication getInstance() 
	{
		if(null == instance)  
	    {  
	    instance = new ExitApplication();  
	    }  
	    return instance;  
	}
	
	public void addActivity(Activity activity)  
    {  
		activityList.add(activity);  
    } 
	
	public void exit()  
    {  
		for(int i=0; i<activityList.size(); i++)   
	    {  
			((Activity) activityList.get(i)).finish();  
	    }  
	    System.exit(0);  
    }    
}
